<form id="<?php echo $uniqid;?>" method="post" style="padding: 8px;">
	<table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable datagrid-toolbar">
		<tr bgcolor="#FFFFFF">
			<td>
				<input type="text" style="width:200px;" v-model="keywords"
					   class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox"
					   placeholder="">
				<a href="javascript:void(0);" @click="search();" class="l-btn l-btn-small l-btn-plain"><span
						class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span class="l-btn-text">过滤</span></span></a>
			</td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td colspan="2">
				<ul id="selectqudaiareaMenu" name="menu_ids"></ul>
			</td>
		</tr>
	</table>
</form>

<script>
	var selectqudaiareaVm = new Vue({
		el: '#<?php echo $uniqid;?>',
		data: {
			treeData: JSON.parse('<?php echo json_encode($areas, JSON_UNESCAPED_UNICODE);?>'),
			keywords: '',
		},
		mounted() {
			this.init();
		},
		methods: {
			init(){
				$('#selectqudaiareaMenu').tree({
					data: this.treeData,
					lines: true,
				}).tree('collapseAll');
			},
			search(){
				$.messager.progress();
				$.post('/admin/member/qudailevel', {keywords: selectqudaiareaVm.keywords}, (data)=> {
					$.messager.progress('close');
					if (data.ret === 0) {
						this.treeData = data.data;
						$('#selectqudaiareaMenu').tree({
							data: this.treeData,
							lines: true,
						}).tree('expandAll');
					} else {
						$.messager.alert('提示', data.msg, 'warning');
					}
				});
			},
		}
	});
	$('#qudailevelsubmit').click(function (data) {
		var row = $('#selectqudaiareaMenu').tree('getSelected');
		if (!row) {
			$.messager.alert('提示', '请先选择要代理商区域！', 'warning');
		}else{
			let area = {
				id: row.id,
				level: row.level,
				text: row.text
			};
			$.messager.progress();
			$.post('/admin/member/setQudai', {id: '<?php echo $id;?>', area: area}, function (data) {
				$.messager.progress('close');
				if (data.ret === 0) {
					$.messager.show({
						title: '提示',
						msg: data.msg,
						timeout: 3000,
						showType: 'slide'
					});
					membereditVm.params.qudai = data.data;
					$("#membereditdlg").dialog('close');
				} else {
					$.messager.alert('提示', data.msg, 'warning');
				}
			}, 'json');
		}
	});
</script>
